<template>
	<view style="padding: 40rpx;">
		<view class="main">
			<view class="ui-left">
				<text class="ui-name">网点: </text>
				<picker style="width: 550rpx;" @change="bindPickerChange" mode='selector' range-key="branchName"
					:value="branchCode" :range="typeList">
					<view class="picker">
						{{branchName || '请选择'}}
					</view>
				</picker>
			</view>
		</view>
		<view class="" style="justify-content: center;margin-top: 100rpx;">
			<button type="primary" @tap="toNext()" width="550rpx">下一步</button>
		</view>
	</view>
</template>

<script>
	import Vue from 'vue'

	import api from '@/common/vmeitime-http/'
	//全局注入w-loading组件
	Vue.prototype.$api = api
	export default {
		data() {
			return {
				typeList: [],
				branchCode: "",
				branchName: ""
			}
		},
		onLoad(options) {
			this.getlistType()
			// this.getBluetooth()
		},
		methods: {
			bindPickerChange(e) {
				console.log(e);
				this.branchCode = this.typeList[e.detail.value].branchCode
				this.branchName = this.typeList[e.detail.value].branchName
			},
			getlistType() {
				this.$api.admin({
					apiUrl: '/system/config',
					param: {
						"code": "ROUTE_PUSH_CN_BRANCH"
					}
				}).then((res) => {
					this.typeList = res.data.data.data
				}).catch((err) => {})
			},
			toNext() {
				if (!this.branchCode) {
					uni.showLoading({
						title: '请选择网点',
						icon: 'none',
						duration: 2000
					});
					return
				}
				uni.navigateTo({
					url: '/pages/index/solicitationDetail?branchCode=' + this.branchCode + '&branchName=' + this.
					branchName
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.main {
		padding: 20rpx;

		.ui-name {
			font-size: 28rpx;
			width: 80rpx;
		}

		.ui-left {
			display: flex;
			flex-direction: row;
			align-items: center;

			.picker {
				background-color: #efefef;
				padding: 20rpx;
				margin-left: 10rpx;
				font-size: 30rpx;
				color: #666;
			}
		}
	}
</style>